﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Workflow.ComponentModel.Compiler;
using CommonLibrary.Wf.InterFace;

namespace ServiceApplication.Service.WorkFlow.WorkflowDesignerApp
{
    class 等待审批提交Validator : ActivityValidator
    {
        public override ValidationErrorCollection ValidateProperties(ValidationManager manager, object obj)
        {
            if (Application.ExecutablePath.EndsWith("devenv.exe"))
                return base.ValidateProperties(manager, obj);

            ValidationErrorCollection validationErrors = base.ValidateProperties(manager, obj);
            等待审批提交 activity = obj as 等待审批提交;
            if (activity != null)
            {
                if (string.IsNullOrEmpty(activity.Description))
                {
                    validationErrors.Add(ValidationError.GetNotSetValidationError("Description"));
                }

                if (string.IsNullOrEmpty(activity.处理人.处理者类型))
                {
                    validationErrors.Add(ValidationError.GetNotSetValidationError("处理者类型"));
                }
                else if (activity.处理人.处理者类型 != TaskClrType.发起人.ToString() &&
                    activity.处理人.处理者类型 != TaskClrType.由上一步处理人指定.ToString())
                {
                    if (activity.处理人.处理人编码.Length < 1)
                    {
                        validationErrors.Add(ValidationError.GetNotSetValidationError("处理者编码"));
                    }
                }
            }
            return validationErrors;
        }

    }
}
